<div class="row">

    <div class="col-md-12">      		
    	
    	<div class="widget stacked ">

            <div class="widget-header">
                <i class="icon-list"></i>
                <h3><?php echo isset($title_for_layout)?$title_for_layout:$this->l('List of users'); ?></h3>
            </div> <!-- /.widget-header -->

            <div class="widget-content">

            <form action="<?php echo base_url('Doctor/Patient/'); ?>" method="get" style="width: 100%;">
                    <div class="form-group">
                        <span class="col-md-8">
                            <a class="btn btn-success" href="<?php echo base_url('Doctor/Patient/create'); ?>"><?php echo $this->l('Add a patient'); ?></a>
                        </span>
                        
                        <div id="search" class="col-md-4">
                            <label class="col-md-4" for="inputquery" style=" line-height: 34px; ">
                                <?php echo $this->l('Search'); ?>
                            </label>
                        
                            <div class="input-group">
                                <input id="inputquery" class="form-control" type="text" name="q" value="<?php echo $q; ?>" />
                                <span class="input-group-btn">
                                    <button class="btn btn-primary" type="submit"><?php echo $this->l('Go!'); ?></button>
                                </span>
                            </div><!-- /input-group -->
                        </div>
                        <input type="hidden" name="filter_reset" value="1" />
                        <input type="hidden" name="order_reset" value="1" />
                    </div>
                    <div class="clearfix"></div>
                </form>
                
                <div class="collapse navbar-collapse navbar-ex1-collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown-submenu"><a tabindex="-1" href="<?php echo base_url('Doctor/Patient/?filter_reset=1'); ?>"><?php echo $this->l('All patients'); ?></a></li>
                        <li><a href="<?php echo base_url('Doctor/Patient/?filter_by=is_connected&filter_val=1'); ?>"><?php echo $this->l('Connected'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Patient/?filter_by=activated&filter_val=2'); ?>"><?php echo $this->l('Activated'); ?></a></li>
                        <li><a href="<?php echo base_url('Doctor/Patient/?filter_by=activated&filter_val=1'); ?>"><?php echo $this->l('Confirmed'); ?></a></li>
                        <li><a href="<?php echo base_url('Doctor/Patient/?filter_by=activated&filter_val=0'); ?>"><?php echo $this->l('Not confirmed'); ?></a></li>
                    </ul>
                </div><!-- /.navbar-collapse -->
                
                <br />                
     
                
                <section id="tables">
                    <div class="page-header">
                        <h3><?php echo $title; ?></h3>
                    </div>
                    
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover table-striped">
                            <thead>
                                <tr>
                                    <th><a href="<?php echo site_url('Doctor/Patient/?q='); echo urlencode($q) .'&order_by=id_user&order_way='. (($order_by == 'id_user' && $order_way == 'DESC')?'ASC':'DESC'); ?>"><?php echo $this->l('#'); ?><?php echo (($order_by == 'id_user')?(($order_way == 'DESC')?' (v)':' (^)'):''); ?></a></th>
                                    <th><a href="<?php echo site_url('Doctor/Patient/?q='); echo urlencode($q) .'&order_by=email&order_way='. (($order_by == 'email' && $order_way == 'DESC')?'ASC':'DESC'); ?>"><?php echo $this->l('Email'); ?><?php echo (($order_by == 'email')?(($order_way == 'DESC')?' (v)':' (^)'):''); ?></a></th>
                                    <th><a href="<?php echo site_url('Doctor/Patient/?q='); echo urlencode($q) .'&order_by=username&order_way='. (($order_by == 'username' && $order_way == 'DESC')?'ASC':'DESC'); ?>"><?php echo $this->l('Patient'); ?><?php echo (($order_by == 'username')?(($order_way == 'DESC')?' (v)':' (^)'):''); ?></a></th>
                                    <th><a href="<?php echo site_url('Doctor/Patient/?q='); echo urlencode($q) .'&order_by=activated&order_way='. (($order_by == 'activated' && $order_way == 'DESC')?'ASC':'DESC'); ?>"><?php echo $this->l('Status'); ?><?php echo (($order_by == 'activated')?(($order_way == 'DESC')?' (v)':' (^)'):''); ?></a></th>
                                    <th class="td-actions" width="130"></th>
                                </tr>
                            </thead>
                            <tbody>
                        		<?php foreach ($items as $k => $v): ?>
                        			<tr>
                        				<td><?php echo $v->id_user; ?></td>
                        				<td><?php echo $v->email; ?></td>
                        				<td><?php echo $v->username .' ['. $v->firstname .' '. $v->lastname .']'; ?></td>
                        				<td><?php echo ($v->activated == '0') ? $this->l('Not confirmed') : ( ($v->activated == '2') ? $this->l('Activated') : $this->l('Confirmed') ); ?> 
                                            [ <?php echo ($v->is_connected == '0') ? $this->l('Not connected') : $this->l('Connected'); ?> ] </td>
                        				
                						<td class="td-actions">
                							
                							<a title="<?php echo $this->l('View this patient'); ?>" href="<?php echo site_url('Doctor/Patient/viewPatient/?id='. (int)$v->id_user); ?>" title="<?php echo $this->l('View'); ?>" class="btn btn-xs btn-primary">
                								<i class="btn-icon-only icon-eye-open"></i>										
                							</a>
                							<a title="<?php echo $this->l('Edit this patient'); ?>" href="<?php echo site_url('Doctor/Patient/editPatient/?id='. (int)$v->id_user); ?>" title="<?php echo $this->l('Edit'); ?>"class="btn btn-xs btn-primary">
                								<i class="btn-icon-only icon-edit"></i>										
                							</a>
                                            <a title="<?php echo ($v->activated == '0') ? $this->l('Activate this patient') : (($v->activated == '1') ? $this->l('Activate this patient') : $this->l('Deactivate this patient')); ?>" 
                                                href="<?php echo ($v->activated == '0') ? site_url('Doctor/Patient/activatePatient/?act=on&id='. (int)$v->id_user) : (($v->activated == '1') ? site_url('Doctor/Patient/activatePatient/?act=on&id='. (int)$v->id_user) : site_url('Doctor/Patient/activatePatient/?act=off&id='. (int)$v->id_user)); ?>" title="<?php echo $this->l('Enabled'); ?>" 
                                                class="btn btn-xs <?php echo ($v->activated == '0') ? 'btn-primary' : (($v->activated == '1') ? 'btn-primary' : 'btn-danger hidden'); ?>" title="<?php echo ($v->activated == '0') ? $this->l('Disabled') : $this->l('Enabled'); ?>">
                                                <i class="btn-icon-only icon-ok"></i>                                       
                                            </a>
                						</td>
                        			</tr>
                        		<?php endforeach ?>
                            </tbody>
                        </table>
                    </div> <!-- /.table-responsive -->

                     <?php include(((BASEPATH == '/')?'':dirname(BASEPATH)).'/'.APPPATH.'views/Templates/pagination.php'); ?>
                    
                </section>
    			
    		</div> <!-- /widget-content -->
    			
    	</div> <!-- /widget -->
    	
    </div> <!-- /span12 -->

</div> <!-- /row -->